package io.renren.modules.generator.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.renren.modules.generator.dao.CardtypeDao;
import io.renren.modules.generator.dao.DepartmentDao;
import io.renren.modules.generator.dao.EmployeeDao;
import io.renren.modules.generator.dao.JobcodeDao;
import io.renren.modules.generator.dao.JobgradecodeDao;
import io.renren.modules.generator.dao.SchoolDao;
import io.renren.modules.generator.entity.CardtypeEntity;
import io.renren.modules.generator.entity.DepartmentEntity;
import io.renren.modules.generator.entity.EmployeeEntity;
import io.renren.modules.generator.entity.EmployeeVO;
import io.renren.modules.generator.entity.JobcodeEntity;
import io.renren.modules.generator.entity.JobgradecodeEntity;
import io.renren.modules.generator.entity.SchoolEntity;
import io.renren.modules.generator.service.EmployeeService;
import io.renren.util.UUIDUtil;



@Service("employeeService")
public class EmployeeServiceImpl extends BaseServiceImpl implements EmployeeService {
	
	
	@Override
	public EmployeeEntity queryObject(String employeeno){
		return employeeDao.queryObject(employeeno);
	}
	
	@Override
	public List<EmployeeEntity> queryList(Map<String, Object> map){
		return employeeDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return employeeDao.queryTotal(map);
	}
	
	@Override
	public void save(EmployeeEntity employee){
		employee.setEmployeeno(UUIDUtil.getOrderIdByUUId());
		employeeDao.save(employee);
	}
	
	@Override
	public void update(EmployeeEntity employee){
		employeeDao.update(employee);
	}
	
	@Override
	public void delete(String employeeno){
		employeeDao.delete(employeeno);
	}
	
	@Override
	public void deleteBatch(String[] employeenos){
		employeeDao.deleteBatch(employeenos);
	}
	
	@Override
	public EmployeeVO findAllinit() {
		EmployeeVO employeeVO = new EmployeeVO();
		List<SchoolEntity> schoolList = schoolDao.findAllSchool();
		if(null != schoolList && schoolList.size() > 0){
			employeeVO.setSchool(schoolList);
		}else{
			employeeVO.setSchool(new ArrayList<SchoolEntity>());
		}
		List<CardtypeEntity> cardtypeList = cardtypeDao.queryList(new HashMap<>());
		if(null != cardtypeList && cardtypeList.size() > 0){
			employeeVO.setCardtype(cardtypeList);
		}else{
			employeeVO.setCardtype(new ArrayList<>());
		}
		List<DepartmentEntity> departmentList = departmentDao.queryList(new HashMap<>());
		if(null != departmentList && departmentList.size() > 0){
			employeeVO.setDepartment(departmentList);
		}else{
			employeeVO.setDepartment(new ArrayList<>());
		}
		List<JobcodeEntity> jobCodeList = jobCodeDao.queryList(new HashMap<>());
		if(null != jobCodeList && jobCodeList.size() > 0){
			employeeVO.setJobcode(jobCodeList);
		}else{
			employeeVO.setJobcode(new ArrayList<>());
		}
		List<JobgradecodeEntity> jobgradecodeList =jobgradecodeDao.queryList(new HashMap<>());
		if(null != jobgradecodeList && jobgradecodeList.size() > 0){
			employeeVO.setJobgradecode(jobgradecodeList);
		}else{
			employeeVO.setJobgradecode(new ArrayList<>());
		}
		
		return employeeVO;
	}
	
}
